package com.xone.xapp;

import org.json.JSONArray;
import org.json.JSONObject;

public class PurchaseListHolder extends BasicListHolder {
	protected String id;
	protected String purchaseName;
	protected String dateCreated;
	protected String purchaseTypeName;
	protected String purchaseLocation;
	protected String purchaseDesc;
	protected boolean top;
	protected String [] ids;
	public PurchaseListHolder(JSONObject jSONObject) {
		id = JSONUtils.getStringFromJSONObject(jSONObject, "id");
		purchaseName = JSONUtils.getStringFromJSONObject(jSONObject, "purchaseName");
		dateCreated = JSONUtils.getStringFromJSONObject(jSONObject, "dateCreated");
		if (null != dateCreated) {
			dateCreated = dateCreated.replaceFirst("T", " ");
		}
		top = JSONUtils.getBooleanFromJSONObject(jSONObject, "top");
		purchaseTypeName = JSONUtils.getStringFromJSONObject(jSONObject, "purchaseTypeName");
		purchaseLocation = JSONUtils.getStringFromJSONObject(jSONObject, "purchaseLocation");
		purchaseDesc = JSONUtils.getStringFromJSONObject(jSONObject, "purchaseDesc");
		JSONArray jids = JSONUtils.getJSONArrayForKey(jSONObject, "ids");
		if (null != jids && jids.length() > 0) {
			ids = new String [jids.length()];
			for (int i = 0; i < jids.length(); i++) {
				ids[i] = JSONUtils.getStringFromJSONArray(jids, i);
			}
		}
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getPurchaseName() {
		return purchaseName;
	}
	public void setPurchaseName(String purchaseName) {
		this.purchaseName = purchaseName;
	}
	public void setDateCreated(String dateCreated) {
		this.dateCreated = dateCreated;
	}
	public String getPurchaseTypeName() {
		return purchaseTypeName;
	}
	public void setPurchaseTypeName(String purchaseTypeName) {
		this.purchaseTypeName = purchaseTypeName;
	}
	public String getPurchaseLocation() {
		return purchaseLocation;
	}
	public void setPurchaseLocation(String purchaseLocation) {
		this.purchaseLocation = purchaseLocation;
	}
	public String getPurchaseDesc() {
		return purchaseDesc;
	}
	public void setPurchaseDesc(String purchaseDesc) {
		this.purchaseDesc = purchaseDesc;
	}
	public boolean isTop() {
		return top;
	}
	public void setTop(boolean top) {
		this.top = top;
	}
	public String[] getIds() {
		return ids;
	}
	public void setIds(String[] ids) {
		this.ids = ids;
	}
	@Override
	public String getDateCreated() {
		return dateCreated;
	}
	@Override
	public String getDataCreatedName() {
		return "purchase.dateCreated";
	}

}
